var gl_vue_vm_list_total_html = $('#vue_vm_list_total').html();
var gl_vue_vm_list_detail_html = $('#vue_vm_list_detail').html();

$(function() {
	$('#vue_vm_list_total').hide();
	$('#vue_vm_list_detail').hide();
});

var asset = {
	assetId: '',
	assetName: '',
	price: '',
	createTime: '',
	updateTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
};

findTotal();
findDetail();

function getTotalMoney(assetForms) {
	var totalMoney = 0;
	
	if(assetForms) {
		for(var i=0; i<assetForms.length; i++) {
			totalMoney += assetForms[i].price * assetForms[i].quantity;
		}
	}
	
	return totalMoney;
}

function findTotal() {
	if($('#vue_vm_list_total').length==0) {return;}
	$('#vue_vm_list_total').hide();

	findAll_basic(path+'/roomAsset/findAll', function(response) {
		$('#vue_vm_list_total').html(gl_vue_vm_list_total_html);
		
		new Vue({
			el: '#vue_vm_list_total',
			data: {
				todos: response.data
			},
			methods: {
				getTotalMoney:function(assetForms) {
					return getTotalMoney(assetForms);
				}
			}
		});
		
		$('#vue_vm_list_total').show();
	});
}

function findDetail() {
	if($('#vue_vm_list_detail').length==0) {return;}
	$('#vue_vm_list_detail').hide();

	findAll_basic(path+'/roomAsset/findBuilding', function(response) {
		$('#vue_vm_list_detail').html(gl_vue_vm_list_detail_html);
		
		new Vue({
			el: '#vue_vm_list_detail',
			data: {
				todos: response.data
			},
			methods: {
				getTotalMoney:function(assetForms) {
					return getTotalMoney(assetForms);
				}
			}
		});
		
		$('#vue_vm_list_detail').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/asset/deleteBatch');
}